Repository navigation
fix(ci): detect stale workflow-file drift before it silently no-ops the agent step - #255
Merged
Merged
Conversation
…he agent step
GitHub refuses to mint the OIDC token claude-code-action needs
(id-token: write, pull_request-triggered) whenever the running
workflow's own file on the PR branch doesn't byte-match dev's copy —
its own anti-tampering check. The agent step still reports success
when this happens (the token exchange fails inside the action, not
the step), so a stale PR branch touching one of these three workflow
files silently produces no verdict at all, and the fallback logic
reports a misleading generic message ("produced neither a verdict
file nor a verdict comment line") that sends humans down the wrong
troubleshooting path.
Live-hit on PR #234 (issue #254): 14 commits behind dev, with
qa-agent.yml among 7 diverged workflow files, failed identically
twice.
Add a preemptive git-diff check (against dev) of each workflow's own
file, right after the PR branch is checked out and before its agent
step runs. On drift, skip the agent step and post a distinct,
actionable comment ("this PR's branch is stale relative to dev —
rebase and retry") instead of running a doomed OIDC exchange and
falling through to the generic no-verdict message. Applied to all
three pipeline workflows (dev-agent.yml, qa-agent.yml,
principal-review.yml) since they share the identical
claude-code-action + id-token:write + pull_request pattern; scoped to
dev-agent.yml's revise mode only, since triage mode never checks out
a PR branch.
Closes #254
Contributor
📱 iOS Build Status: PASSED✅ iOS Simulator Build & Unit Tests - success iOS UI tests run in a separate, informational job and are not reflected above — check "iOS UI Tests (informational)" for those. |
Collaborator
|
Automated pipeline health check (2026-08-17): This PR needs a human look — I can't confidently diagnose why it's stuck.
Since this diff touches Generated by Claude Code |
libravault-xyz
added a commit
that referenced
this pull request
Aug 18, 2026
Reviewed as principal dev lead: this is the fix for #231 (guard-step crash silently mislabeling a PR), CI green (required checks). Rebased and manually resolved a real conflict against #255 (both touched the same 'Advance PR' step) — merged the two independent checks in sensible order: guard-crash check first, then PR_NUMBER assignment, then workflow-drift check, unchanged from there. Merging directly since this is a sensitive workflow-file path.
This was referenced Aug 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
dev-agent.yml,qa-agent.yml, andprincipal-review.ymlall useanthropics/claude-code-actionwithpermissions: id-token: writeon apull_request-triggered job. GitHub's own anti-tampering check refuses to mint that OIDC token whenever the running workflow's own file on the PR branch doesn't byte-match the copy ondev— this is GitHub protecting against a PR modifying the very workflow that's about to run with elevated trust. When that happens, the "Run agent" step itself still reportssuccessin the Actions UI (the token exchange fails inside the action, not the step), so the agent silently never ran, and the workflow falls through to its generic "produced neither a verdict file nor a verdict comment line" message — which is misleading, since nothing actually ran, and sends a human down the wrong troubleshooting path (confirmed live on PR #234 in issue #254, first assumed to be an LLM/prompt bug).Closes #254
Approach
Rather than the log-scraping approach the issue floats as a fallback (grep the job log for "Workflow validation failed" after the fact), this detects the condition proactively: right after each workflow checks out the PR branch — and before its agent step runs — a new step does:
If that workflow's own file has drifted from
dev, the agent step is skipped outright (viaif: ... && steps.workflow-drift.outputs.drift != 'true'), and the "advance PR" step posts a distinct, actionable comment ("this PR's branch is stale relative to dev — rebasedevin and re-add the triggering label") instead of running a doomed OIDC exchange and reporting the old generic message. Routes tostatus:needs-infowithout consumingqa-agent.yml's auto-retry budget — this is a pipeline/tooling failure, not a real finding, matching how the existing crash-handling branches in each workflow already reason about the same distinction.Applied to all three pipeline workflows since they share the identical
claude-code-action+id-token: write+pull_requestpattern (per the issue: "This isn't specific to qa-agent"):qa-agent.yml— checked unconditionally (every run operates on an existing PR branch).principal-review.yml— same, unconditionally.dev-agent.yml— scoped to revise mode only (steps.guard.outputs.mode == 'revise'). Triage mode never checks out a PR branch before its own agent step (it runs from the default branch checkout), so its own copy ofdev-agent.ymlis alreadydev's copy — the drift condition can't occur there.I deliberately did not implement the issue's other suggested option (a rebase-before-agent self-heal step) or touch PR #234 itself — the issue explicitly frames the immediate unblock (rebasing #234) as a separate human decision, and a full self-heal-by-rebase adds real complexity (force-push semantics, conflict handling) for a problem this simpler skip-and-report fix already resolves at the "stop misleading humans" level the issue's root complaint is about.
Risk
This diff touches
.github/workflows/**, one ofagent-policy.yml'ssensitive_paths—classify_pr_risk.pywill forcerisk:highon this PR regardless of QA/review outcome, so it always lands onstatus:needs-human-merge, never auto-merged. Flagging explicitly per the dev-agent persona's instructions.The new steps only run
git fetch/git diff(noghcalls, no token needed beyond whatactions/checkoutalready persists) — low blast radius. Worst case of a bug in the new check is a false skip (an agent run that would have worked gets skipped and routed tostatus:needs-infoinstead) — recoverable by a human re-applying the triggering label, same recovery path the pre-existing malfunction/crash branches already rely on.Testing
No JVM/Kotlin code is touched, so
./gradlew testDebugUnitTestis not relevant here (nothing in that suite exercises workflow YAML). Validated:yaml.safe_load).if:conditions and GitHub Actions' implicit-success()semantics by hand to confirm the new step composes correctly with each workflow's existing skip/crash/verdict branches (in particular, that referencing an unset step output likesteps.workflow-drift.outputs.driftwhen that step didn't run —dev-agent.ymltriage mode — evaluates to empty string, not an error, so the agent step still runs normally in that mode).run:blocks (only.github/scripts/*.shgetstest_resolve_linked_issue.sh-style shell tests) — this pipeline's own workflow logic has historically been validated live, per the "confirmed live" write-ups throughoutdocs/agent-team-pipeline.mdand the other workflow files' comments. I could not exercise this change against a real stale-branch PR without creating one.